package org.tokaf;

import java.util.Comparator;
import java.util.Vector;

import org.tokaf.normalizer.Normalizer;

/**
 * <p> MyVectorCompare compares two vectors by specified index, using given
 * Normalizer. </p> <p> Copyright (c) 2006 </p> <p>
 * @author Alan Eckhardt
 * @version 1.0
 */
public class MyVectorCompare implements Comparator {
	int index;

	Normalizer norm;

	public MyVectorCompare(int index, Normalizer norm) {
		this.index = index;
		this.norm = norm;
	}

	public int compare(Object o1, Object o2) {
		if (o1 instanceof Vector && o2 instanceof Vector) {
			Object oo1 = ((Vector) o1).get(index);
			Object oo2 = ((Vector) o2).get(index);
			return norm.compare(oo1, oo2);
		}
		return 0;
	}
}
